﻿using BreacherCreature.Components.Lights;
using King.Engine.GameObjects;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BreacherCreature.GameObjects
{
    class LightSwitch : GameObject
    {
        #region Fields

        SwitchDirection _direction;

        #endregion

        #region Properties

        public SwitchState State;

        #endregion

        #region Constructor

        public LightSwitch(int x, int y, SwitchDirection direction, bool startState)
        {
            Bounds = new Rectangle(x, y, 100, 100);
            State = startState ? SwitchState.On : SwitchState.Off;
        }

        #endregion

        #region Public Methods

        public void SwitchOff()
        {
            State = SwitchState.Off;
            var lights = GetComponents<LightField>();
            foreach (LightField light in lights)
                light.FlickerOff();
        }

        public void SwitchOn()
        {
            State = SwitchState.On;
            var lights = GetComponents<LightField>();
            foreach (LightField light in lights)
                light.FlickerOn();
        }

        public void SwitchToggle()
        {
            if (State == SwitchState.On)
                SwitchOff();
            else
                SwitchOn();
        }

        #endregion
    }

    public enum SwitchState
    {
        On,
        Off
    }

    public enum SwitchDirection
    {
        Up,
        Down,
        Left,
        Right
    }
}
